package org.example;

import java.util.Arrays;

import static java.lang.Thread.sleep;

public class FlagDemo {
    private static volatile boolean running = true;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            Integer size = 0;
            while (running == true) {
            }
            System.out.println("running is false");
            return;
        });
        t1.start();
        sleep(2000);
        running = false;
        t1.join();
    }
}
